package com.zqxq.lottery.api.utils;

import org.apache.log4j.Logger;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2018/1/27.
 */
public class RequestUtils {
    private static Logger logger = Logger.getLogger(RequestUtils.class);
    public static void logRequest(HttpServletRequest request) {

        logger.info("=========== this is debug begin =============");
        logger.info("RequestURI():" + request.getRequestURI());
        logger.info("QueryString():" + request.getQueryString());
        logger.info("------------- header -------------");
        for (java.util.Enumeration<String> ss = request.getHeaderNames(); ss.hasMoreElements(); ) {
            String s = ss.nextElement();
            logger.info(s + ":" + request.getHeader(s));
        }

        logger.info("------------- parameter -------------");
        for (java.util.Enumeration<String> pns = request.getParameterNames(); pns.hasMoreElements(); ) {
            String s = pns.nextElement();
            logger.info(s + ":" + request.getParameter(s));
        }

        logger.info("------------- sessionid:" + request.getSession().getId());
        for (java.util.Enumeration<String> pns = request.getSession().getAttributeNames(); pns.hasMoreElements(); ) {
            String s = pns.nextElement();
            logger.info(s + ":" + request.getSession().getAttribute(s));
        }

        logger.info("=========== this is debug end =============");
    }

}
